<?php
//include "include/global.php";
$color=isset($_REQUEST['color'])?trim($_REQUEST['color']):"255,255,255";
$width=isset($_REQUEST['width'])?intval($_REQUEST['width']):95;
$height=isset($_REQUEST['height'])?intval($_REQUEST['height']):45;
session_start();
Header("Content-type: image/jpeg");
srand((double)microtime()*1000000);
$randval = sprintf("%04d", rand(0,9999));
$_SESSION['session_verify'] = $randval;
if(function_exists('imagecreatetruecolor')) {
	$im = @imagecreatetruecolor($width,$height);
}else {
	$im = @imagecreate($width,$height);
}
$color=explode(',',$color);
$backColor = ImageColorAllocate($im,$color['0'],$color['1'],$color['2']);//背景色（随机）
$borderColor = ImageColorAllocate($im,$color['0'],$color['1'],$color['2']);//边框色
$pointColor = ImageColorAllocate($im, 0,0,0);//点颜色

@imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor);
$stringColor = ImageColorAllocate($im, 0,0,0);
for($i=0;$i<=10;$i++){
	$pointX = rand(2,$width-2);
	$pointY = rand(2,$height-2);
	@imagesetpixel($im, $pointX, $pointY, $pointColor);
}
@imagestring($im, 5, 25, 16, $randval, $stringColor);
Imagejpeg($im);
@ImageDestroy($im);
?>